
function getEleInnerHtml(id) {
  return document.getElementById(id) && document.getElementById(id).innerHTML || ''
}

const env = 'production' // 'development' or 'production'
const TEST = 0
const FOOTER_SHOW_TIME = 3 * 1000
const version = 1.0
const DEBUG = true
let wsBaseUrl = getEleInnerHtml('socket_domain_area') ? getEleInnerHtml('socket_domain_area') : 'wss://live-socket.chinatravelacademy.com'
const WS_URL = {
  development: (code) => {
    return `${wsBaseUrl}?code=${code}`
  },
  production: (code) => {
    return `${wsBaseUrl}?code=${code}`
  }
}

const HOSTS = {
  development: 'https://www.putong.17baa.com',
  production: getEleInnerHtml('host_domain_area') ? getEleInnerHtml('host_domain_area') : 'https://live.chinatravelacademy.com'
}


// apis
const API = {
  DO_STAR_QUESTION: (type, id, token) => {
    return `${HOSTS[env]}/live/question/up/${type}/${id}?__token=${token}`
  },
  REPLAY_DATA: (id, token) => {
    return HOSTS[env] + '/live/room/' + id + '/playback?__token=' + token + '&test=0&applet-name=two'
  },
  POST_CODE: (code) => {
    return HOSTS[env] + '/web/pc-code?code=' + code
  },
  GET_USER_LIST: (id, token) => {
    return HOSTS[env] + '/live/room/' + id + '/users?test=' + TEST + '&__token=' + token
  }
}

module.exports = {
  env,
  version,
  API,
  WS_URL: WS_URL[env],
  HOSTS: HOSTS[env],
  TEST,
  DEBUG,
  FOOTER_SHOW_TIME
}
